<template>
  <div class="agora-video-player" id="domId"></div>
</template>

<script>
export default {
  name: '',
  props: {
    stream:{
      type:Object
    },
    domId:{
      type:[Number,String]
    },
    isSub:{
      type:Boolean,
      default:false
    },// 是否远端流
  },
  data () {
    return {
    };
  },
  components: {},
  computed: {},
  watch: {},
  mounted () {
    this.$nextTick(()=> {
        // 如果是本地流，一定要在创建流成功后(localStream.init)再执行播放
        console.log('是否需要播放',this.stream)
        if (this.stream && !this.stream.isPlaying()) {
          console.log('需要播放')
          this.stream.play(`domId`)
        }
    })
  },
  methods: {
  },
  beforeDestroy () {
    // 远端流
    if (this.isSub && this.stream) {
      if (this.stream.isPlaying()) {
        this.stream.stop()
      }
      this.stream.close()
    }
  }
}
</script>
<style lang='scss' scoped>
.agora-video-player{
    width: 100%;
    height: 100%;
}
</style>